package com.platform.api;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.platform.annotation.IgnoreAuth;
import com.platform.entity.FootprintEntity;
import com.platform.service.FootprintService;
import com.platform.util.ApiBaseAction;
import com.platform.utils.R;

import io.swagger.annotations.Api;

@Api(tags = "API足迹接口")
@RestController
@RequestMapping("/api/foot")
public class ApiFootprintController extends ApiBaseAction {
    @Autowired
    private FootprintService footprintService;
    
    /**
     * 查看列表
     */
    @RequestMapping("/list")
    public R list(
    		@RequestParam Map<String, Object> map) {
    	Integer userId = super.getCurrentUserId();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("isLast", 1);
        params.put("userId", userId);
        params.put("sidx", "id");
        params.put("order", "desc");
        
        if(map.get("offset") != null) {
            params.put("offset", Integer.valueOf(map.get("offset").toString()));
        }else {
            params.put("offset", 0);
        }
        if(map.get("limit") != null) {
            params.put("limit", Integer.valueOf(map.get("limit").toString()));
        }else {
            params.put("limit", 6);
        }
        
        List<FootprintEntity> goodsList = footprintService.queryList(params);
        return R.ok().put("goodsList", goodsList);
    }
    
}
